#!/bin/bash

make veryclean; make
for i in `ls input/`
do
echo $i
./compiler.exe < input/$i > lista
mkdir output/$(echo $i | sed -e 's/\.cre/\.d/')
gcc -Wall -pedantic -ansi output/code.c -o output/$(echo $i | sed -e 's/\.cre/\.d/')/$(echo $i | sed -e 's/\.cre/\.out/')
mv output/code.c output/$(echo $i | sed -e 's/\.cre/\.d/')/$(echo $i | sed -e 's/\.cre/\.c/')
mv output/code.ic output/$(echo $i | sed -e 's/\.cre/\.d/')/$(echo $i | sed -e 's/\.cre/\.ic/')
mv output/syntax.ast output/$(echo $i | sed -e 's/\.cre/\.d/')/$(echo $i | sed -e 's/\.cre/\.ast/')
echo '================================================================================'
done
